#ifndef CLIENT_H
#define CLIENT_H

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <pthread.h>
#include <stdbool.h>
#include <time.h>
#include "common.h"

#define SERVER_IP "127.0.0.1"
#define SERVER_PORT 8080
#define BUFFER_SIZE 4096
#define TIMEOUT_SEC 5

typedef struct {
    int sockfd;
    pthread_mutex_t mutex;
    pthread_cond_t cond;
    bool response_received;
    char response[BUFFER_SIZE];
    int  response_length;
    bool socket_closed;
} ClientContext;

extern ClientContext ctx;

extern void* receiver_thread(void *arg);
extern bool send_request(const char *request,const int request_length, char *response, int *response_length);
extern void* heartbeat_thread(void *arg);


#endif //CLIENT_H
